<?php
	class Topic extends MY_controller{

		function __construct(){
			parent::__construct();
		}

		public function index($limit = 0){
			$this->load->model("Tk_test_topic_historys");
			$this->load->model("Subjects");
			$conditions['school_id'] = $this->school_id;
			$this->offset = 1;
			if($limit > 0 && is_ajax_request()) $limit = ($limit - 1) * $this->offset;
			$subject_data = $this->Subjects->get_subject_list($limit, $this->offset, $conditions);
			$this->smarty->assign("limit", $limit);
			if(is_ajax_request()){
				if(!empty($subject_data['result'])){
					echo json_encode($subject_data['result']);
				}else{
					echo json_encode(array());
				}
				exit;
			}
			$this->smarty->assign("count", ceil($subject_data['count'] / $this->offset)+1);
			$this->smarty->assign("subject_list", $subject_data['result']);
			$this->smarty->display("tiku/index.html");
		}
	}